package webExperiment;

import java.util.Random;

public class usefull {
    public static void doPause(int iTimeInMesSec) {
	long t0, t1;
	t0 = System.currentTimeMillis();
	t1 = System.currentTimeMillis() + (iTimeInMesSec);
	do {
	    t0 = System.currentTimeMillis();
	} while (t0 < t1);
    }

    public static int convertToMath(int ang) {
	ang = 360 - ang + 90; // gegen Urzeigersinn
	if (ang >= 360)
	    ang = ang - 360;
	if (ang < 0)
	    ang = ang + 360;
	return ang;
    }

    public static int bool2int(boolean b) {
	if (b)
	    return 1;
	else
	    return 0;
    }

    public static String getJavaVersion() {
	return System.getProperty("java.version") + " ("
		+ System.getProperty("java.vendor") + ")";
    }

    public static String getRandomParticipantCode() {
	String code = "";
	Random random = new Random();
	for (int i = 1; i <= 12; i++) {
	    if (i > 1 && (i % 4) == 1) {
		code = code + "-";
	    }
	    code = code + random.nextInt(10);
	}
	return code;
    }
}
